package com.shuai.frame.registry;

import com.shuai.frame.config.XsRPCRegistryCenterConfig;
import com.shuai.frame.model.ServiceMetaInfo;

import java.util.List;
import java.util.concurrent.ExecutionException;

/**
 * 提供类似序列化器实现的注册中心接口，后续可支持用户通过API动态自定义配置中心
 */
public interface RegistryCenter {
    /**
     * 初始化
     */
    void init(XsRPCRegistryCenterConfig config);

    /**
     * 注册服务
     */
    void register(ServiceMetaInfo serviceMetaInfo) throws ExecutionException, InterruptedException;

    /**
     * 注销服务
     */
    void unregister(ServiceMetaInfo serviceMetaInfo) throws ExecutionException, InterruptedException;

    /**
     * 服务发现
     */
    List<ServiceMetaInfo> serviceDiscover(String serviceKey) throws ExecutionException, InterruptedException;

    /**
     * 服务销毁
     */
    void destroyService();

    void heartBeat();

    /**
     * 消费者端监听
     */
    void watch(String serviceKey);
}
